package com.ruoyi.web.controller.facilities;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.facilities.domain.TfGasgc;
import com.ruoyi.facilities.service.ITfGasgcService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 废气治理设施Controller
 * 
 * @author yxf
 * @date 2021-08-10
 */
@RestController
@RequestMapping("/facilities/atmosphere")
public class TfGasgcController extends BaseController
{
    @Autowired
    private ITfGasgcService tfGasgcService;

    /**
     * 查询废气治理设施列表
     */
    @PreAuthorize("@ss.hasPermi('facilities:atmosphere:list')")
    @GetMapping("/list")
    public TableDataInfo list(TfGasgc tfGasgc)
    {
        startPage();
        List<TfGasgc> list = tfGasgcService.selectTfGasgcList(tfGasgc);
        return getDataTable(list);
    }

    /**
     * 导出废气治理设施列表
     */
    @PreAuthorize("@ss.hasPermi('facilities:atmosphere:export')")
    @Log(title = "废气治理设施", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TfGasgc tfGasgc)
    {
        List<TfGasgc> list = tfGasgcService.selectTfGasgcList(tfGasgc);
        ExcelUtil<TfGasgc> util = new ExcelUtil<TfGasgc>(TfGasgc.class);
        return util.exportExcel(list, "废气治理设施数据");
    }

    /**
     * 获取废气治理设施详细信息
     */
    @PreAuthorize("@ss.hasPermi('facilities:atmosphere:query')")
    @GetMapping(value = "/{etfId}")
    public AjaxResult getInfo(@PathVariable("etfId") Long etfId)
    {
        return AjaxResult.success(tfGasgcService.selectTfGasgcById(etfId));
    }

    /**
     * 新增废气治理设施
     */
    @PreAuthorize("@ss.hasPermi('facilities:atmosphere:add')")
    @Log(title = "废气治理设施", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TfGasgc tfGasgc)
    {
        return toAjax(tfGasgcService.insertTfGasgc(tfGasgc));
    }

    /**
     * 修改废气治理设施
     */
    @PreAuthorize("@ss.hasPermi('facilities:atmosphere:edit')")
    @Log(title = "废气治理设施", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TfGasgc tfGasgc)
    {
        return toAjax(tfGasgcService.updateTfGasgc(tfGasgc));
    }

    /**
     * 删除废气治理设施
     */
    @PreAuthorize("@ss.hasPermi('facilities:atmosphere:remove')")
    @Log(title = "废气治理设施", businessType = BusinessType.DELETE)
	@DeleteMapping("/{etfIds}")
    public AjaxResult remove(@PathVariable Long[] etfIds)
    {
        return toAjax(tfGasgcService.deleteTfGasgcByIds(etfIds));
    }
}
